package leetcode.new_wrold;

public class T26 {
    public int removeDuplicates(int[] nums) {
        int step = 0;
        int length = nums.length;
        if (length==0 || length==1){
            return length;
        }
        for (int i = 1;i < length;i++){
            if (nums[i]==nums[i-1]){
                step++;
                continue;
            }
            nums[i-step] = nums[i];
        }
        return length-step;
    }

    public static void main(String[] args) {
        T26 t26 = new T26();
        int[] nums = new int[]{0,0,1,1,1,2,2,3,3,4};
        int len = t26.removeDuplicates(nums);
        for (int num : nums) {
            System.out.print(num+" ");
        }
        System.out.println();
        System.out.println("len="+len);
    }
}
